<?php
include_once 'lib/config.php';
include_once 'lib/db.php';
include_once 'lib/utils/tag.php';
include_once 'model/departemen.php';
//include_once 'dashboard/model/periode.php';
 
function inject_head(){?>
<link rel="stylesheet" type="text/css" href="css/datepicker_vista.css" /> 
<script type="text/javascript" src="jscript/datepicker.js"></script> 
<script>
	function changePassword($karyID){
		FBModal_show2( 'proc/client/dataUser.php', 'post', "proc=change-password&karyID="+$karyID, true, true);
	}

	function savePassword(form){
		form.opass.value = form.opass.value;//hex_md5(form.opass.value).toLowerCase();
		form.npass.value = form.npass.value;//hex_md5(form.npass.value).toLowerCase();
		form.npass2.value = form.npass2.value;//hex_md5(form.npass2.value).toLowerCase();
		FBModal_loading("Save", "Please wait...", true, false);
		$(form).set('send', {
			method: 'post',
			onSuccess: function(response) { 
				var js = JSON.decode(response);
				var msg = js.error? js.msg : "Process simpan selesai !!!";
				var title = js.error? 'Error' : 'Saving';
				FBModal_show(
					"<h2 class=\"dialog_title\"><span>"+title+"</span></h2>" + 
					"<div class=\"dialog_content\" style=\"padding: 10px 20px\">"+msg+"</div>",
					true, true,1500);
			}
		}).send();
	}
	
	function load_graph(){
		if($('totalPointKaryawan').getStyle('display')=='block')
			APP.totalPointKaryawan.load_graph($('totalPointKaryawan-form'));
		else if($('totalPointDepartemen').getStyle('display')=='block')
			APP.totalPointDepartemen.load_graph($('totalPointDepartemen-form'));
		else if($('prestasiPelanggaranPerBidang').getStyle('display')=='block')
			APP.prestasiPelanggaranPerBidang.load_graph($('prestasiPelanggaranPerBidang-form'));
	}
	
	function load_drillGraph(data){
		if(APP.graphCombo.oldSelected.id == 'totalPointKaryawan')
			APP.totalPointKaryawan.load_drillGraph(data);	
		else if(APP.graphCombo.oldSelected.id == 'totalPointDepartemen')
			APP.totalPointDepartemen.load_drillGraph(data);	
		else if(APP.graphCombo.oldSelected.id == 'prestasiPelanggaranPerBidang')
			APP.prestasiPelanggaranPerBidang.load_drillGraph(data);
	}
	
	
	APP = {
		graphCombo: {
			oldSelected: null
		}	
	};
	
	window.addEvent('domready', function(){
		APP.graphCombo.oldSelected = $('totalPointKaryawan');
		
		$('graphCombo').addEvent('change', function(){
			if (APP.graphCombo.oldSelected){
				APP.graphCombo.oldSelected.setStyle('display','none');
			}
			
			APP.graphCombo.oldSelected = $( $('graphCombo').value );
			APP.graphCombo.oldSelected.setStyle('display','block');
			load_graph();
		});	
		
		load_graph();
	});
</script>
<?php } ?>

<?php include 'view/header.php'; ?>
<h2>Grafik Overview</h2>
<hr />
<table width="100%" border="0">
<tr>
	<td width="100" align="right">Grafik : </td>
    <td>
    <select id="graphCombo" name="graphCombo" onchange="">
    	<option value="totalPointKaryawan">Total Point Karyawan</option>
        <option value="totalPointDepartemen">Total Point Departemen</option>
        <option value="prestasiPelanggaranPerBidang">Prestasi Pelanggaran per Bidang</option>
    </select></td>
</tr>
</table>
<div id="totalPointKaryawan"><?php include 'view/client/dashboard/totalPointKaryawan.php'; ?></div>
<div id="totalPointDepartemen" style="display:none"><?php include 'view/client/dashboard/totalPointDepartemen.php'; ?></div>
<div id="prestasiPelanggaranPerBidang" style="display:none"><?php include 'view/client/dashboard/prestasiPelanggaranPerBidang.php'; ?></div>

<div align="center" id="graphContainer" style="margin-top:20px">
<img id="graph" src="proc/admin/totalPointKaryawan.php?proc=graph" />
</div>

<div style="padding-top:40px"><?php include 'view/client/dashboard/rewardWarning.php'; ?></div>
<?php include 'view/footer.php'; ?>